The Dynamic Host Configuration Protocol (DHCP) is a dynamic address assignment protocol based on the Transmission Control Protocol/Internet Protocol (TCP/IP). In an actual application, a DHCP server assigns an Internet Protocol (IP) address to a user terminal that serves as a DHCP client, so as to avoid an IP address conflict between different user terminals.
If the user terminal and the DHCP server are located in different physical network segments, a DHCP relay device needs to transfer a DHCP packet between the user terminal and the DHCP server. For example, after receiving a Dynamic Host Configuration Protocol discover (DHCP Discover) packet sent by the user terminal, the DHCP relay device may generate a first DHCP packet and send the first DHCP packet to the DHCP server. The DHCP Discover packet may be used to search for the DHCP server. The first DHCP packet includes a gateway interface IP address and a Media Access Control (MAC) address of the user terminal. The gateway interface IP address is an IP address of a physical interface through which the DHCP relay device communicates with the user terminal. The DHCP relay device may further send, to the user terminal, a Dynamic Host Configuration Protocol offer (DHCP Offer) packet from the DHCP server. The DHCP Offer packet includes an IP address provided by the DHCP server to the user terminal. After receiving a Dynamic Host Configuration Protocol request (DHCP Request) packet sent by the user terminal, the DHCP relay device may generate a second DHCP packet and send the second DHCP packet to the DHCP server. The DHCP relay device may further send, to the user terminal, a Dynamic Host Configuration Protocol acknowledgement DHCP ACK) packet from the DHCP server. The DHCP ACK packet includes configuration information of the user terminal. After receiving the DHCP ACK packet, the user terminal may obtain the IP address assigned by the DHCP server to the user terminal.
A network node between the user terminal and the DHCP server needs to support a DHCP relay function, and can generate a DHCP packet. For example, the DHCP relay device may insert information such as the gateway interface IP address into a relay agent information option field, such as an option 82 field, of the received DHCP Discover packet or DHCP Request packet. The network node between the user terminal and the DHCP server further needs to support formats, customized by different operators, of option fields, and the network node between the user terminal and the DHCP server is relatively complex.